<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="/common/taglibs.jsp"%>
<%@ include file="/common-app/taglibs.jsp"%>
<!DOCTYPE html>
<html>
<head>
<title>申请书编辑</title>
<script type="text/javascript" src="${res}/js/jquery/jquery.form.js"></script>
<script type="text/javascript"
	src="${res}/js/proposal/irisPrpPrepare.js"></script>
<script type="text/javascript" src="${res}/js/validate/irisvalidator.js"></script>
<script type="text/javascript" src="${res}/js/keyword/keywordtips.js"></script>
<script type="text/javascript"
	src="${res_app}/js/app/proposal/irisPrpPrepare.js"></script>

<style>
textarea {
	overflow: auto;
}
</style>

<script type="text/javascript">
	$(function() {
		queryflex();
	});
	/**
	 * 申请书提交方法
	 */

	var ctxpath = "${ctx}";
	var prcWin = new progressWin("${res}");//初始化遮罩层
	/**
	 * 页面初始化方法 所有的都定义在里面
	 */
	$(document).ready(
			function() {
				$("#wbox1").click(function() {
					check("check");

				});

				$("#wbox2").click(function() {

					check("check");

				});

				initControl();

				$("table.t_css").not("[id='finances']").not(
						"[id='checkbox_table_']").not("[id='budgetsMsg2']")
						.each(function() {
							$(this).find("tr:even").addClass("li_1");
							$(this).find("tr:odd").addClass("li_2");
						});
				$("table").addClass("table01");
				$("#checkbox_table_").removeClass("table01");
				$("#feaReport_upload").removeClass("table01");
				$('div').find("[id^='checkbox_dyn_']").find("tr").removeClass(
						"li_1").removeClass("li_2");
				$('div').find("[id^='checkbox_dyn_']").find("td").css("border",
						'0px solid');

				updatePdfNotes();
				window.setInterval("checkPdfStatus()", "10000");//检验申请书的pdf
			});

	$(document).ready(function() {
		fileInit("feaReport_upload","PDF");
	/* 	fileInit("prpContent_upload","JPG,PDF,TIFF,XLS,DOC,WPS",null,"{'JPG':'51200','PDF':'51200','TIFF':'51200','XLS':'51200','DOC':'51200','WPS':'51200'}");	
	 */ 
		fileInit("prpContent_upload","JPG,PDF,DOC,DOCX,WPS",null,"");	
	 //fileInitAttach("attachAdd", "JPG,PDF", null, 20, "{'JPG':'3072','PDF':'3072'}");
		$("#prpContent_upload").find(".file").hide();//隐藏文本框
	});

	
	
	
	$(document).ready(function() {
		$("#org").attr("disabled", "true");
		initDepartForComplete("org");
		initControl();
	});

	/**
	 * 申报日期默认为当前日期
	 */
	$(document).ready(function() {

		var nowDate = '${sercverSysDate1}';
		if ($("#submit_date").val() == "") {
			$("#submit_date").val(nowDate);
		}

	});

	/**
	 * 填写检查
	 */
	function check(type) {
		setTotalAmt();
		validate($("#basicInfo1"), "项目基本情況");
		validate($("#basicInfo2"), "项目基本情況");
		validate($("#basicInfo3"), "项目基本情況");
		validate($("#basicInfo4"), "项目基本情況");
		validate($("#basicInfo5"), "项目基本情況");
		validate($("#basicInfo15"), "项目基本情況");
		var keyWordStr = $("#keywords").val();
		keyWordStr = keyWordStr.replace(/,/g, '；');
		var keyWordArr = keyWordStr.split('；');
		/* alert(keyWordArr.length); */

		if (keyWordArr.length > 3) {
			irisValaddMsg("项目基本情況-->中文关键字数量不多于三个");
		}

		var keyWordStrEnglish = $("#keywords_english").val();
		keyWordStrEnglish = keyWordStrEnglish.split("；");
		if (keyWordStrEnglish.length > 3) {
			irisValaddMsg("项目基本情況-->英文关键词数量不多于三个");
		}

		validate($("#basicInfo6"), "项目人员");
  	validateByTabRow($("#zh_persons"), "项目人员-->课题组主要研究人员",2); 
 
		
		
	var submitPsn = $("#submit_psn").parent("td").parent("tr");
	var zh_name = submitPsn.find("span[name$='zh_name']").text();
	var major = submitPsn.find("span[name$='major_work']").text();
	var birthday = submitPsn.find("span[name$='birthday']").text();
	var position = submitPsn.find("span[name$='position']").text();
	var educate_name = submitPsn.find("span[name$='educate_name']").text();
	var work = submitPsn.find("span[name$='work']").text();
	var org_name = submitPsn.find("span[name$='org_name']").text();
	var work_time_name = submitPsn.find("span[name$='work_time_name']").text();
	 
	if (zh_name=="" || major=="" || birthday=="" || position=="" ||work=="" || org_name=="") {
		irisValaddMsg("项目人员-->课题组主要研究人员-->项目负责人信息(课题组主要研究人员第一条)不完整");
	}
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		
		validate($("#basicInfo7"), "项目概况");
		validate($("#basicInfo8"), "项目概况");
		validate($("#basicInfo9"), "项目概况");

		/* validate($("#prj_1"),"项目经费情况"); */
		validate($("#fundInfo"), "项目经费");

		validateByTabRow($("#tblMileStones"), "项目进度", 1);

		/* validate($("#performance"),"项目绩效目标"); */
		
			validate($("#performances"),"项目绩效目标");
		

		validate($("#feaReport_upload"), "项目可行性研究报告");
		validate($("#prpContent_upload"), "附件清单");

		/* validate($("#fragment-tab2"),"项目概况");
		validate($("#fragment-tab3"),"单位信息");
		var submitPsn = $("#submit_psn").parent("td").parent("tr");
		var zh_name = submitPsn.find("span[name$='zh_name']").text();
		var major = submitPsn.find("span[name$='major']").text();
		var birthday = submitPsn.find("span[name$='birthday']").text();
		var position = submitPsn.find("span[name$='position']").text();
		var educate_name = submitPsn.find("span[name$='educate_name']").text();
		var work = submitPsn.find("span[name$='work']").text();
		var org_name = submitPsn.find("span[name$='org_name']").text();
		var prof_title_name = submitPsn.find("span[name$='prof_title_name']").text();
		if (zh_name=="" || major=="" || birthday=="" || position=="" || educate_name=="" || work=="" || org_name=="" || prof_title_name=="") {
			irisValaddMsg("项目人员-->项目负责人信息(项目人员列表第一条)不完整");
		} */
		/* validate($("#tblresume"),"项目人员"); */
		/* validate($("#fragment-tab6"),"经费信息");
		irisJqValEmpty($("#fundAdds"),"经费信息-->新增投入预算请完整填写");
		validateByTabRow($("#tblMileStones"),"进度计划->项目进度信息",1);
		
		irisJqValEmpty($("#fragment-tab8"),"项目绩效-->项目绩效目标表请完整填写");
		validate($("#fragment-tab8"),"项目绩效");
		<security:authorize ifNotGranted="A_DAILU_PROPOSAL">irisFundEmpty($("#finances"),"单位财务信息不完整，请联系单位管理员完善单位信息");</security:authorize><security:authorize ifAnyGranted="A_DAILU_PROPOSAL">irisFundEmpty($("#finances"),"请完善单位信息");</security:authorize>prp_attach();
		validate($("#fragment-tab10"),"可行性报告"); */
		if (!valResult()) {
			irisValShowMsg($("#wbox1"));
			return false;
		}
		if (type == "check") {
			showBox($("#wbox1"), "300px", "200px", "检查通过", "1:所有检查全部合格");
		}
		return true;
	}

	function setTotalAmt() {
		$('#request_amt').val($("#total_invest_0").val());
	}

	function initTreeValueExt(treeId, treeNode) {

		if (!(treeNode && (treeNode.level > 0 || !treeNode.isParent))) {
			scmWarn($("#" + treeId).attr("label")
					+ messageTip.researchAreaInvalidDisciplineCode);
			if (treeNode.level == 0) {
				$("#" + treeId).val("");
				$("#" + treeId).parents("td").find(
						"[name$='" + treeId + "_code'],[id$='" + treeId
								+ "_code']").val("");
				$("#" + treeId).parents("td").find(
						"[name$='" + treeId + "_value'],[id$='" + treeId
								+ "_value']").val("");
				$("#" + treeId).parents("td").find(
						"[name$='" + treeId + "_name'],[id$='" + treeId
								+ "_name']").val("");
			}

			return false;
		}

		var str = treeNode.name;
		var obj = treeNode.parentNode;
		while (obj != null) {
			obj = obj.parentNode;
		}

		$("#" + treeId).parents("td").find(
				"[name$='" + treeId + "_code'],[id$='" + treeId + "_code']")
				.val(treeNode.id);
		$("#" + treeId).parents("td").find(
				"[name$='" + treeId + "_value'],[id$='" + treeId + "_value']")
				.val(treeNode.id);
		$("#" + treeId).parents("td").find(
				"[name$='" + treeId + "_name'],[id$='" + treeId + "_name']")
				.val(str);

	}
</script>
<style>
textarea {
	overflow: auto;
}
</style>
</head>
<body>

	<c:set var="xmlstr" value="${xmlData}" scope="request" />
	<x:parse xml="${xmlstr}" var="xmlData" scope="request" />
	<input type="hidden" id="childDiv" class="thickbox" />
	<input type="hidden" id="filePath"
		value="${ctx}/file/ajax-filedownload?fileCode=" />
	<input type="hidden" id="menuId" value="${param.menuId}" />
	<input type="hidden" id="sysDate" value="${sercverSysDate}" />

	<div id="showMessage"></div>
	<div id="content">

		<cpt:helpTips key="prpedit" id="prpEditTips"></cpt:helpTips>
		<div class="clear_h15"></div>
		<div class="word_box" id="mainDiv">
			<jsp:include page="./prpeditmain_public_first.jsp"><jsp:param
					value="${xmlstr}" name="xmlstr" /></jsp:include>
			<%-- <div class="bar_btn">
				<span class="left"> 
					<c:set var="grantCode"><x:out select="$xmlData/data/proposal/grant_code" /></c:set>
					<c:set var="flag_shizhi"><x:out select="$xmlData/data/proposal/flag_shizhi" /></c:set>
					<input name="Submit" type="button" class="button_01" value="保存" onclick="saveAction()" /> 
					&nbsp; <c:if test="${not empty fbl.pdfViewUrl}"><input name="Submit" type="button" class="button_01" value="下载PDF"  onclick="genPdfAction()"/></c:if>
					<security:authorize ifNotGranted="A_DAILU_PROPOSAL">
					&nbsp; <input name="Submit" type="button" class="button_01"	value="提交给单位管理员" onclick="submitAction()" />
					</security:authorize>
					<security:authorize ifAnyGranted="A_DAILU_PROPOSAL">
					&nbsp; <input name="Submit" type="button" class="button_01"	value="提交到归口管理部门" onclick="submitAction()" />
					</security:authorize> 
					&nbsp; <input name="Submit" type="button" class="button_01" value="返回" onclick="backToList()" />
				</span>
				<span class="right"> 
					<input title="填写检查" class="btn_inspect" type="button" id="wbox1"/>
				</span>
					<c:set var="sub_grant_code"><x:out select="$xmlData/data/proposal/sub_grant_code" /></c:set>
					
			</div> --%>
			<div class="bar_b">
				<input type="hidden" id="pdfStatus" value="${pdfStatus}" /> <span
					class="right">版本号：<span name="proposal/prp_version"
					id="prp_version"><x:out
							select="$xmlData/data/proposal/prp_version" /></span></span>
			</div>
			<form method="post" id="mainForm">
				<input type="hidden" value="${grantCode}" id="grantCode"
					name="grantCode"> <input type="hidden" value="${posCode}"
					id="posCode" name="posCode"> <input type="hidden"
					value="<iris:des3 code="${posCode}"></iris:des3>" id="posCodeDes"
					name="posCodeDes"> <input type="hidden"
					value="<iris:des3 code="${fbl.pdfCode}"></iris:des3>"
					id="pdfCodeDes" name="pdfCodeDes"> <input type="hidden"
					value="${xmlData}" id="xmlData" name="xmlData"> <input
					type="hidden" value="${fbl.pdfCode}" id="pdfCode" name="pdfCode">
				<input type="hidden" value="${flag_shizhi}" id="flag_shizhi"
					name="proposal/flag_shizhi">
			</form>
			<div class="word_title">
				<c:set var="statYear">${statYear}</c:set>
				<c:if test="${empty statYear}">
					<c:set var="statYear">
						<x:out select="$xmlData/data/proposal/stat_year" />
					</c:set>
				</c:if>
				<input type="hidden" name="proposal/stat_year" value="${statYear}">
				<span name="proposal/grant_name"><x:out
						select="$xmlData/data/proposal/grant_name" /></span>-项目申请书 (<span
					name="proposal/stat_year">${statYear}</span>年)<br />
					(<x:out select="$xmlData/data/proposal/sub_grant_name" />)
					 

				<c:set var="formCode">
					<x:out select="$xmlData/data/proposal/form_code" />
				</c:set>

				<input type="hidden" name="organizations/organization[0]@submit_org"
					value="1"> <input type="hidden"
					name="organizations/organization[0]/nature_value"
					value="<x:out select="$xmlData/data/organizations/organization[@submit_org='1']/nature_value" />">

				<c:set var="nature_value">
					<x:out
						select="$xmlData/data/organizations/organization[@submit_org='1']/nature_value" />
				</c:set>
				<c:if test="${empty formCode}">
					<c:set var="formCode" value="${param.formCode}"></c:set>
				</c:if>
				<input type="hidden" name="proposal/form_code" value="${formCode}" />
				<%-- <input type="hidden" name="proposal/request_amt" id="request_amt"
					value="<x:out select="$xmlData/data/proposal/request_amt"/>"> --%>
				<input type="hidden" name="proposal/year" value="${year}" />

				<!-- 公用的配置界面 -->
				<jsp:include page="./prpeditmain_public.jsp"></jsp:include>
			</div>
			<div id="tabnav">
				<ul>
					<li class="down" id="tab1" onclick="changeTab(this.id)"><a
						href="###"><span>项目基本情況</span></a></li>

					<!-- 						<li  class="down" id="tab2" onclick="changeTab(this.id)">
						    <a href="###"><span>项目基本情況</span></a>
						</li>
						 -->
					<li id="tab3" onclick="changeTab(this.id)"><a href="###"><span>项目人员</span></a>
					</li>
					<li id="tab4" onclick="changeTab(this.id)"><a href="###"><span>项目概况</span></a>
					</li>
					<li id="tab5" onclick="changeTab(this.id)"><a href="###"><span>项目经费</span></a>
					</li>

				
					<li id="tab7" onclick="changeTab(this.id)"><a href="###"><span>项目进度</span></a>
					</li>
					<li id="tab8" onclick="changeTab(this.id)"><a href="###"><span>项目绩效目标</span></a>
					</li>
					<li id="tab10" onclick="changeTab(this.id)"><a href="###"><span>项目可行性研究报告</span></a>
					</li>
					<li id="tab9" onclick="changeTab(this.id)"><a href="###"><span>附件清单</span></a>
					</li>


				</ul>
			</div>
			<div class="tab_box" id="fragment-tab1">
				<jsp:include page="../info/prpInfoEdit_zrkxjj.jsp">
					<jsp:param value="${grantName}" name="grantName" />
					<jsp:param value="${statYear}" name="statYear" />
				</jsp:include>
			</div>


			 <div class="tab_box" id="fragment-tab3" style="display: none">
				<jsp:include page="../psn/prpzhpsn_zrkxjj1.jsp">
						<jsp:param value="项目人员情况（限20人）" name="title" />
				</jsp:include>
			</div>
			
			
			
			
			<div class="tab_box" id="fragment-tab4" style="display: none">
				<jsp:include page="../goal/prpgoaledit_zrkxjj.jsp"></jsp:include>
			</div>


			<div class="tab_box" id="fragment-tab5" style="display: none">
				<jsp:include page="../fund/prpfundedit_zrkxjj.jsp">
					<jsp:param value="${statYear}" name="statYear" />
					<jsp:param value="项目经费" name="title" />
					<jsp:param value="（单位：万元，保留两位小数）" name="unit" />
				</jsp:include>
			</div>

			





			<div class="tab_box" id="fragment-tab7" style="display: none">
				<jsp:include page="../milestone/prpmilestoneedit_zrkxjj.jsp"></jsp:include>
			</div>



			<div class="tab_box" id="fragment-tab8" style="display: none">
				<jsp:include page="../performance/prpperformanceedit_zrkxjj.jsp">
					<jsp:param value="项目绩效目标" name="title" />
				</jsp:include>
			</div>

		
			<div class="tab_box" id="fragment-tab9" style="display: none">
				<jsp:include page="../attach/prpAttachEdit_by_zrkxjj.jsp">
					 <jsp:param value="${xmlstr}" name="xmlstr" />
				</jsp:include>
			</div>

			<div class="tab_box" id="fragment-tab10" style="display: none">
				<jsp:include page="../content/prpContentEdit_zrkxjj.jsp"></jsp:include>
			</div>

			<jsp:include page="./prpeditmain_public_last.jsp"><jsp:param
					value="${xmlstr}" name="xmlstr" /></jsp:include>
		
		</div>
		<div class="clear_h15"></div>
	</div>
</body>

</html>